package com.csw.spark

import org.apache.spark.rdd.RDD
import org.apache.spark.{SparkConf, SparkContext}

object Demo12MapValues {
  def main(args: Array[String]): Unit = {

    val conf: SparkConf = new SparkConf()
      .setMaster("local")
      .setAppName("mapValues")

    val sc: SparkContext = new SparkContext(conf)

    val aggRDD: RDD[(String, Int)] = sc.parallelize(List(("001", 23), ("002", 24), ("003", 25)))

    /**
      *
      * mapValues：处理kv格式的rdd， 只处理value key不变
      *
      */
    val rdd1: RDD[(String, Int)] = aggRDD.mapValues(value => value + 100)

    rdd1.foreach(println)
  }
}
